package com.xidian.zhiancloud.service.exam.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.xidian.zhiancloud.dao.exam.TExamQuestionMapper;
import com.xidian.zhiancloud.model.exam.TExamQuestion;
import com.xidian.zhiancloud.service.exam.ITExamQuestionService;
import com.xidian.zhiancloud.util.api.DateUtils;

/**
 * 试题Service业务层处理
 * 
 * @author zhouweitao
 * @date 2021-03-05
 */
@Service
public class TExamQuestionServiceImpl implements ITExamQuestionService 
{
    @Autowired
    private TExamQuestionMapper tExamQuestionMapper;

    /**
     * 查询试题
     * 
     * @param id 试题ID
     * @return 试题
     */
    @Override
    public TExamQuestion selectTExamQuestionById(Long id)
    {
        return tExamQuestionMapper.selectTExamQuestionById(id);
    }

    /**
     * 查询试题列表
     * 
     * @param tExamQuestion 试题
     * @return 试题
     */
    @Override
    public Page<TExamQuestion> selectTExamQuestionList(TExamQuestion tExamQuestion)
    {
    	PageHelper.startPage(tExamQuestion.getPageNum()-1, tExamQuestion.getPageSize());
    	//Page<TExamQuestion> pagedata =  tExamQuestionMapper.selectTExamQuestionList(tExamQuestion);
        return tExamQuestionMapper.selectTExamQuestionList(tExamQuestion);
    }

    /**
     * 新增试题
     * 
     * @param tExamQuestion 试题
     * @return 结果
     */
    @Override
    public int insertTExamQuestion(TExamQuestion tExamQuestion)
    {
        tExamQuestion.setCreateTime(DateUtils.getNowDate());
        return tExamQuestionMapper.insertTExamQuestion(tExamQuestion);
    }

    /**
     * 修改试题
     * 
     * @param tExamQuestion 试题
     * @return 结果
     */
    @Override
    public int updateTExamQuestion(TExamQuestion tExamQuestion)
    {
        tExamQuestion.setUpdateTime(DateUtils.getNowDate());
        return tExamQuestionMapper.updateTExamQuestion(tExamQuestion);
    }

    /**
     * 批量删除试题
     * 
     * @param ids 需要删除的试题ID
     * @return 结果
     */
    @Override
    public int deleteTExamQuestionByIds(Long[] ids)
    {
        return tExamQuestionMapper.deleteTExamQuestionByIds(ids);
    }

    /**
     * 删除试题信息
     * 
     * @param id 试题ID
     * @return 结果
     */
    @Override
    public int deleteTExamQuestionById(Long id)
    {
        return tExamQuestionMapper.deleteTExamQuestionById(id);
    }
}
